Push three items into the Heap and print the items¶
Push three items into the Heap and print the items from the heap.
Expected output:
(‘V’, 1)
(‘V’, 2)
(‘V’, 3)
import heapq
heap = []
heapq.heappush(heap, ('V', 1))
heapq.heappush(heap, ('V', 2))
heapq.heappush(heap, ('V', 3))
for item in heap:
print(item)
Output:
('V', 1)
('V', 2)
('V', 3)